package com.huangjue.backend.service.impl;

import com.huangjue.backend.entity.Submission;
import com.huangjue.backend.mapper.SubmissionMapper;
import com.huangjue.backend.service.SubmissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 作业提交服务实现类
 */
@Service
public class SubmissionServiceImpl implements SubmissionService {
    @Autowired
    private SubmissionMapper submissionMapper;

    /** 新增提交记录（学生提交作业） */
    @Override
    public boolean addSubmission(Submission submission) {
        return submissionMapper.insert(submission) > 0;
    }

    /** 查询某作业下某学生的提交记录 */
    @Override
    public Submission getSubmissionByHomeworkIdAndUserId(Integer homeworkId, Integer userId) {
        return submissionMapper.selectByHomeworkIdAndUserId(homeworkId, userId);
    }

    /** 查询某学生的所有提交记录 */
    @Override
    public List<Submission> getSubmissionsByUserId(Integer userId) {
        return submissionMapper.selectByUserId(userId);
    }

    /** 查询某作业的所有提交记录 */
    @Override
    public List<Submission> getSubmissionsByHomeworkId(Integer homeworkId) {
        return submissionMapper.selectByHomeworkId(homeworkId);
    }
} 